"""
倍数重排

125874和它的两倍251748拥有同样的数字，只是排列顺序不同。有些正整数x满足2x、3x、4x、5x和6x都拥有相同的数字，
求其中最小的正整数。
"""

def same_num(m,n):
    for i in str(m):
        if str(m).count(i)!=str(n).count(i):
            return False
    else:
        return True

num=1
while True:
    if same_num(num,2*num):
        if same_num(num,3*num):
            if same_num(num,4*num):
                if same_num(num,5*num):
                    if same_num(num,6*num):
                        print(num)
                        break
    num+=1





# def SameDigit(exlist):#判断数字相同
#     for i in  exlist:
#         if set(i)!=set(exlist[0]):
#             return False
#     return True
# Number=1
# while 1:
#     Nlist=[str(i*Number) for i in range(1,7)]
#     if SameDigit(Nlist):
#         print(Nlist)
#         break
#     else:
#         Number+=1
# 答案：['142857', '285714', '428571', '571428', '714285', '857142']
# 结果：142857.